<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改公司')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-company-edit" th:object="${company}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">用户ID：</label>
                <div class="col-sm-8">
                    <input name="memberId" th:field="*{memberId}" class="form-control" type="text" readonly>
                </div>
            </div>
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label">公司头像：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="companyAvatar" th:field="*{companyAvatar}" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">
                <label class="col-sm-3 control-label">公司头像：</label>
                <div class="col-sm-8">
                    <button type="button" class="layui-btn" id="test1">上传图片</button>
                    <div class="layui-upload-list">
                        <div id="img_header" style="padding: 5px;"><img th:src="*{companyAvatar}" style='height: 60px;width: 60px'></div>
                        <input type="hidden" id="companyAvatar" name="companyAvatar" th:field="*{companyAvatar}">
                        <p id="demoText1"></p>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">公司名称：</label>
                <div class="col-sm-8">
                    <input name="companyName" th:field="*{companyName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">公司地址：</label>
                <div class="col-sm-8">
                    <input name="companyAddr" th:field="*{companyAddr}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">企业电话：</label>
                <div class="col-sm-8">
                    <input name="companyPhone" th:field="*{companyPhone}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">发新闻：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('member_news_close')}">
                        <input type="radio" th:id="${'newsClose_' + dict.dictCode}" name="newsClose" th:value="${dict.dictValue}" th:field="*{newsClose}">
                        <label th:for="${'newsClose_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">知名企业：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('company_is_famous')}">
                        <input type="radio" th:id="${'isFamous_' + dict.dictCode}" name="isFamous" th:value="${dict.dictValue}" th:field="*{isFamous}">
                        <label th:for="${'isFamous_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">行情官：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('member_quotation')}">
                        <input type="radio" th:id="${'quotation' + dict.dictCode}" name="quotation" th:value="${dict.dictValue}" th:field="*{quotation}">
                        <label th:for="${'quotation' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">排序：</label>
                <div class="col-sm-8">
                    <input name="sort" th:field="*{sort}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "jiaqin/company";
        $("#form-company-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-company-edit').serialize());
            }
        }

        layui.use('upload', function() {
            var $ = layui.jquery
                , upload = layui.upload;

            //普通图片上传
            var uploadInst = upload.render({
                elem: '#test1'
                , url: '/common/upload' //改成您自己的上传接口
                , done: function (res) {
                    //如果上传失败
                    if (res.code > 0) {
                        return layer.msg('上传失败');
                    }
                    //上传成功
                    $("#img_header ").html("<img src='" + res.url + "' style='width:80px;height:80px;'>");
                    $("#companyAvatar").val(res.url);
                }
                , error: function () {
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText1');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function () {
                        uploadInst.upload();
                    });
                }
            });
        })
    </script>
</body>
</html>
